package com.huatai.datacenter.mapper;

import com.huatai.datacenter.entity.Index.IndexValuesVO;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author gusiyi
 * @version 1.0
 * @className IndexMapper
 * @description 描述：
 * @date 2023/7/18 17:31
 */
public interface IndexMapper {

	/**
	 * 获取数据源占比
	 * @return
	 */
	@Select("SELECT dataSourceType as `name`,count(*) as `value` FROM tb_datasource GROUP BY `name`")
	List<IndexValuesVO> getDataSourceRate();

	/**
	 * 获取集群占比
	 * @return
	 */
	@Select("SELECT a.clusterName as `name`,Count(b.id) as `value` FROM tb_cluster a LEFT JOIN tb_topic_task_info b on a.id = b.clusterId GROUP BY `name`")
	List<IndexValuesVO> getClusterRate();

	/**
	 * 获取模型占比
	 * @return
	 */
	@Select("SELECT a.data_model_name as `name`,Count(b.id) as `value` FROM tb_data_model a LEFT JOIN tb_topic_task_info b on a.id = b.modelId GROUP BY `name`")
	List<IndexValuesVO> getModelRate();

}
